package hd;

import java.util.Objects;

/**
 * @author oldliu
 * @since 1.0
 */
public class Dog  {
    private String name;
    private int age;
    private String color;

    public Dog() {
    }

    public Dog(String name, int age, String color) {
        this.name = name;
        this.age = age;
        this.color = color;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Dog dog = (Dog) o;//强转 向下
        return age == dog.age && Objects.equals(name, dog.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, age);
    }

    @Override
    public String toString() {
        return "狗{" +
                "名字='" + name + '\'' +
                ", 年龄=" + age +
                ", 毛色='" + color + '\'' +
                '}';
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    public void cry(){
        System.out.println(name+"在叫：汪汪汪");
    }
    public void eat(){
        System.out.println(name+"在吃饭");
    }
    public void run(){
        System.out.println("小狗"+name+"在跑");
    }
    public void grab(Mouse m){
        System.out.println(name+"抓住了老鼠"+m.getName());
    }
    public void grab(YellowMouseWolf w){
        System.out.println(name+"抓住了黄鼠狼"+w.getName());
    }
    public void grab(Rabbit b){
        System.out.println(name+"抓住了兔子"+b.getName()+",主人夸她了");
    }
}
